//
//  GuideViewController.m
//  美食百科
//
//  Created by dllo on 16/1/30.
//  Copyright © 2016年 doll. All rights reserved.
//

#import "GuideViewController.h"
#import "ViewController.h"
#define kWidth self.view.frame.size.width
#define kHeight self.view.frame.size.height
@interface GuideViewController ()<UIScrollViewDelegate>
@property(nonatomic,retain)UIScrollView *scrol;
@property(nonatomic,retain)UIPageControl *page;
@end

@implementation GuideViewController
- (void)dealloc
{
    [_scrol release];
    [_page release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
   // self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = YES;
    self.navigationController.navigationBar.translucent = NO;
   self.scrol = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
    self.scrol.delegate = self;
    self.scrol.showsHorizontalScrollIndicator = NO;
    self.scrol.contentSize = CGSizeMake(kWidth*2, 0);
    self.scrol.pagingEnabled = YES;
    self.scrol.bounces = NO;
    self.scrol.tag = 100;
    [self.view addSubview:self.scrol];
    [_scrol release];
    
    UIImageView *imageViewFiest = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight)];
    imageViewFiest.image = [UIImage imageNamed:@"20140805160215_ZWU5w.thumb.700_0"];
   // imageViewFiest.backgroundColor = [UIColor orangeColor];
    [self.scrol addSubview:imageViewFiest];
    [imageViewFiest release];
    
    UIImageView *imageViewSecond = [[UIImageView alloc]initWithFrame:CGRectMake(kWidth, 0, kWidth, kHeight)];
   // imageViewFiest.backgroundColor = [UIColor grayColor];
imageViewSecond.image = [UIImage imageNamed:@"20150129111741_vUm8R.thumb.700_0"];
    imageViewSecond.userInteractionEnabled = YES;
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(kWidth/3-20, kHeight-70, kWidth/3+40, 30);

    [button setTitle:@"开启健康美食之旅" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(clickAction:) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor colorWithRed:0.804 green:0.855 blue:0.318 alpha:1.00];
    button.layer.cornerRadius = 5;
    button.layer.masksToBounds = YES;
    button.alpha =0.9;
    [imageViewSecond addSubview:button];
    
    
    [self.scrol addSubview:imageViewSecond];
    [imageViewSecond release];

    self.page = [[UIPageControl alloc]initWithFrame:CGRectMake(kWidth/2-20, kHeight-30, 40, 20)];
    self.page.backgroundColor = [UIColor colorWithRed:0.702 green:0.627 blue:0.557 alpha:1.00];
    self.page.alpha = 0.9;
    self.page.layer.cornerRadius = 5;
    self.page.layer.masksToBounds = YES;
    [self.page addTarget:self action:@selector(pageAction:) forControlEvents:UIControlEventValueChanged];
    self.page.numberOfPages = 2;
    self.page.pageIndicatorTintColor = [UIColor grayColor];
    [self.view addSubview:self.page];
    [_page release];


}

-(void)clickAction:(UIButton *)button
{
    ViewController *view = [[ViewController alloc]init];
    
    
    [self.navigationController pushViewController:view animated:YES];
    [view release];
}


-(void)pageAction:(UIPageControl *)page
{
  self.scrol.contentOffset = CGPointMake(page.currentPage*kWidth, 0);
    
    
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
        self.page.currentPage =  scrollView.contentOffset.x/kWidth;
}

- (BOOL)prefersStatusBarHidden{
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
